
import java.util.List;

/**
 * User that can place bets on games
 */
public class User {
    private final GameService gameService;

    private String UserName;

    public User(GameService gameService, String UserName, String FirstName, String LastName, String Email) {
        this.gameService = gameService;
        this.UserName = UserName;
        this.FirstName = FirstName;
        this.LastName = LastName;
        this.Email = Email;
    }

    /**
     * Get the value of Name
     *
     * @return the value of Name
     */
    public String getUserName() {
        return UserName;
    }
    
    private String FirstName;

    /**
     * Get the value of FirstName
     *
     * @return the value of FirstName
     */
    public String getFirstName() {
        return FirstName;
    }
    
    private String LastName;

    /**
     * Get the value of LastName
     *
     * @return the value of LastName
     */
    public String getLastName() {
        return LastName;
    }
    
    private String Email;

    /**
     * Get the value of Email
     *
     * @return the value of Email
     */
    public String getEmail() {
        return Email;
    }

    private int Credits;

    /**
     * Get the value of Credits
     *
     * @return the value of Credits
     */
    public int getCredits() {
        return Credits;
    }
    
    /**
     * Get the value of Points
     *
     * @return the value of Points
     */
    public int getPoints() {
        //Could be placed in stored procedure too
        List<Bet> bets = getBets();
        int pointSum = 0;
        
        for(Bet bet : bets) {
            pointSum += bet.getPoints(this);
        }
        
        return pointSum;
    }

    public List<Bet> getBets() {
        return gameService.getBets(this);
    }
    
    public void placeBet(Game game, int guestTeamScore, int homeTeamScore) {
        Bet bet = new Bet(this, game, guestTeamScore, homeTeamScore);
        gameService.placeBet(bet);
    }    
}
